﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsTest.Public
{
    public enum OperatorLabelEnum
    {
        HOME,
        //销售
        ORDER_MANAGER,
        ORDER_ADD,
        ORDER_REJECT,
        ORDER_AUDIT,
        ORDER_COMPARE,
        //采购
        PURCHASE_PRICE,
        PURCHASE_PLAN,
        PURCHASE_MANAGER,
        PURCHASE_ADD,
        PURCHASE_AUDIT,
        PURCHASE_PAY,
        PURCHASE_REJECT,
        //库存
        RESERVE_SEARCH,
        RESERVE_IN,
        RESERVE_OUT,
        RESERVE_MOVE,
        RESERVE_COUNT,
        RESERVE_PRODUCTMANAGER,

        //进销存管理
        BUSIMANAGER_CUSTOM,
        BUSIMANAGER_PROVIDE,
        BUSIMANAGER_TEMPLATE,
        BUSIMANAGER_STORAGE,
        BUSIMANAGER_TODO,

        //系统管理
        SYSTEM_USER,
        SYSTEM_QUARTZ,
        SYSTEM_PARAM,
        SYSTEM_DATABAK,
        SYSTEM_LOGGER,
        SYSTEM_POST,
        SYSTEM_DEPT,
        SYSTEM_ROLE


    }
    public enum WindowModel
    {
        DEFAULT, MANAGER_SEARCH, PANEL_ONLY_CONTROL
    }
    public class Operator
    {
        public static System.Collections.Hashtable hashTable = new System.Collections.Hashtable();
        
        static Operator()
        {
            OperatorModel op = new OperatorModel(OperatorLabelEnum.HOME, "主页");
            op.MainTabClass = "WindowsFormsTest.IndexTab";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.busi_todo;
            hashTable.Add(OperatorLabelEnum.HOME,op);
             //销售
            op = new OperatorModel(OperatorLabelEnum.ORDER_MANAGER, "订单管理");
            op.MainTabClass = "WindowsFormsTest.Sell.SellOrderManager";
            op.BGImager=global::WindowsFormsTest.Properties.Resources.manager;
            hashTable.Add(OperatorLabelEnum.ORDER_MANAGER, op);

            op = new OperatorModel(OperatorLabelEnum.ORDER_ADD, "新增销售订单");
            op.MainTabClass = "WindowsFormsTest.Sell.SellOrderAdd";
            op.BGImager=global::WindowsFormsTest.Properties.Resources.add;
            hashTable.Add(OperatorLabelEnum.ORDER_ADD, op);

            op = new OperatorModel(OperatorLabelEnum.ORDER_REJECT, "退回订单");
            op.MainTabClass = "WindowsFormsTest.Sell.SellOrderManager";
            op.BGImager=global::WindowsFormsTest.Properties.Resources.back;
            op.windowModel = WindowModel.MANAGER_SEARCH;
            hashTable.Add(OperatorLabelEnum.ORDER_REJECT, op);

            op = new OperatorModel(OperatorLabelEnum.ORDER_AUDIT, "销售订单审批");
            op.MainTabClass = "WindowsFormsTest.Sell.SellOrderManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.audit;
            op.windowModel = WindowModel.MANAGER_SEARCH;
            hashTable.Add(OperatorLabelEnum.ORDER_AUDIT, op);


            op = new OperatorModel(OperatorLabelEnum.ORDER_COMPARE, "销售对账单");
            op.MainTabClass = "WindowsFormsTest.Sell.SellOrderManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.sale_compare;
            op.windowModel = WindowModel.MANAGER_SEARCH;
            hashTable.Add(OperatorLabelEnum.ORDER_COMPARE, op);
            //采购
            op = new OperatorModel(OperatorLabelEnum.PURCHASE_PRICE, "供应商报价管理");
            op.MainTabClass = "WindowsFormsTest.Purchase.ProviderPriceManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.purchase_price;
            hashTable.Add(OperatorLabelEnum.PURCHASE_PRICE, op);

            op = new OperatorModel(OperatorLabelEnum.PURCHASE_PLAN, "采购计划");
            op.MainTabClass = "WindowsFormsTest.Purchase.PurchasePlanManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.purchase_plan;
            hashTable.Add(OperatorLabelEnum.PURCHASE_PLAN, op);

            op = new OperatorModel(OperatorLabelEnum.PURCHASE_MANAGER, "采购单管理");
            op.MainTabClass = "WindowsFormsTest.Purchase.PurchaseOrderManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.manager;
            hashTable.Add(OperatorLabelEnum.PURCHASE_MANAGER, op);

            op = new OperatorModel(OperatorLabelEnum.PURCHASE_ADD, "新增采购订单");
            op.MainTabClass = "WindowsFormsTest.Purchase.PurchaseOrderAdd";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.add;
            hashTable.Add(OperatorLabelEnum.PURCHASE_ADD, op);

            op = new OperatorModel(OperatorLabelEnum.PURCHASE_AUDIT, "采购订单审批");
            op.MainTabClass = "WindowsFormsTest.Purchase.PurchaseOrderManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.audit;
            op.windowModel = WindowModel.MANAGER_SEARCH;
            hashTable.Add(OperatorLabelEnum.PURCHASE_AUDIT, op);

            op = new OperatorModel(OperatorLabelEnum.PURCHASE_PAY, "采购付款单管理");
            op.MainTabClass = "WindowsFormsTest.Purchase.PurchaseOrderManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.audit;
            op.windowModel = WindowModel.MANAGER_SEARCH;
            hashTable.Add(OperatorLabelEnum.PURCHASE_PAY, op);

            op = new OperatorModel(OperatorLabelEnum.PURCHASE_REJECT, "采购退货");
            op.MainTabClass = "WindowsFormsTest.Purchase.PurchaseOrderManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.back;
            op.windowModel = WindowModel.MANAGER_SEARCH;
            hashTable.Add(OperatorLabelEnum.PURCHASE_REJECT, op);
            //库存
            op = new OperatorModel(OperatorLabelEnum.RESERVE_SEARCH, "库存查询");
            op.MainTabClass = "WindowsFormsTest.Reserve.ReserveSearch";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.query;
            hashTable.Add(OperatorLabelEnum.RESERVE_SEARCH, op);

            op = new OperatorModel(OperatorLabelEnum.RESERVE_IN, "产品入库");
            op.MainTabClass = "WindowsFormsTest.Reserve.ReserveIn";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.reserve_in;
            hashTable.Add(OperatorLabelEnum.RESERVE_IN, op);

            op = new OperatorModel(OperatorLabelEnum.RESERVE_OUT, "产品出库");
            op.MainTabClass = "WindowsFormsTest.Reserve.ReserveOut";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.reserve_out;
            hashTable.Add(OperatorLabelEnum.RESERVE_OUT, op);
            //需要处理
            op = new OperatorModel(OperatorLabelEnum.RESERVE_MOVE, "库存管理");
            op.MainTabClass = "WindowsFormsTest.Reserve.ReserveManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.reserve_move;
            hashTable.Add(OperatorLabelEnum.RESERVE_MOVE, op);
            //需要处理
            op = new OperatorModel(OperatorLabelEnum.RESERVE_COUNT, "库存盘点");
            op.MainTabClass = "WindowsFormsTest.Reserve.ReserveOut";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.reserve_count;
            hashTable.Add(OperatorLabelEnum.RESERVE_COUNT, op);


            op = new OperatorModel(OperatorLabelEnum.RESERVE_PRODUCTMANAGER, "产品管理");
            op.MainTabClass = "WindowsFormsTest.Reserve.ProductManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.manager;
            hashTable.Add(OperatorLabelEnum.RESERVE_PRODUCTMANAGER, op);

            //进销存管理
            op = new OperatorModel(OperatorLabelEnum.BUSIMANAGER_CUSTOM, "客户管理");
            op.MainTabClass = "WindowsFormsTest.BusiManager.ProviderManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.busi_custom;
            hashTable.Add(OperatorLabelEnum.BUSIMANAGER_CUSTOM, op);

            op = new OperatorModel(OperatorLabelEnum.BUSIMANAGER_PROVIDE, "供应商管理");
            op.MainTabClass = "WindowsFormsTest.BusiManager.ProviderManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.busi_provide;
            hashTable.Add(OperatorLabelEnum.BUSIMANAGER_PROVIDE, op);
            //未处理
            op = new OperatorModel(OperatorLabelEnum.BUSIMANAGER_TEMPLATE, "单据模板维护");
            op.MainTabClass = "WindowsFormsTest.BusiManager.ProviderManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.busi_template;
            hashTable.Add(OperatorLabelEnum.BUSIMANAGER_TEMPLATE, op);

            op = new OperatorModel(OperatorLabelEnum.BUSIMANAGER_STORAGE, "仓库管理");
            op.MainTabClass = "WindowsFormsTest.BusiManager.StorageManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.busi_storage;
            hashTable.Add(OperatorLabelEnum.BUSIMANAGER_STORAGE, op);
            //未处理
            op = new OperatorModel(OperatorLabelEnum.BUSIMANAGER_TODO, "待办查询");
            op.MainTabClass = "WindowsFormsTest.BusiManager.StorageManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.busi_todo;
            hashTable.Add(OperatorLabelEnum.BUSIMANAGER_TODO, op);

            //系统管理
            op = new OperatorModel(OperatorLabelEnum.SYSTEM_USER, "用户管理");
            op.MainTabClass = "WindowsFormsTest.SysManager.UserManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.sys_user;
            hashTable.Add(OperatorLabelEnum.SYSTEM_USER, op);

            op = new OperatorModel(OperatorLabelEnum.SYSTEM_ROLE, "角色/权限管理");
            op.MainTabClass = "WindowsFormsTest.SysManager.RoleManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.sys_role;
            hashTable.Add(OperatorLabelEnum.SYSTEM_ROLE, op);

            op = new OperatorModel(OperatorLabelEnum.SYSTEM_DEPT, "部门管理");
            op.MainTabClass = "WindowsFormsTest.SysManager.DeptManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.sys_dept;
            hashTable.Add(OperatorLabelEnum.SYSTEM_DEPT, op);

            op = new OperatorModel(OperatorLabelEnum.SYSTEM_POST, "职位管理");
            op.MainTabClass = "WindowsFormsTest.SysManager.PostManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.sys_post;
            hashTable.Add(OperatorLabelEnum.SYSTEM_POST, op);

            op = new OperatorModel(OperatorLabelEnum.SYSTEM_LOGGER, "日志管理");
            op.MainTabClass = "WindowsFormsTest.SysManager.LogManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.sys_logger;
            hashTable.Add(OperatorLabelEnum.SYSTEM_LOGGER, op);

            op = new OperatorModel(OperatorLabelEnum.SYSTEM_DATABAK, "数据备份");
            op.MainTabClass = "WindowsFormsTest.SysManager.DataManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.sys_databak;
            hashTable.Add(OperatorLabelEnum.SYSTEM_DATABAK, op);
            /*
            op = new OperatorModel(OperatorLabelEnum.SYSTEM_QUARTZ, "定时任务");
            op.MainTabClass = "WindowsFormsTest.SysManager.LogManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.sys_quartz;
            hashTable.Add(OperatorLabelEnum.SYSTEM_QUARTZ, op);
             */

            op = new OperatorModel(OperatorLabelEnum.SYSTEM_PARAM, "参数维护");
            op.MainTabClass = "WindowsFormsTest.SysManager.ParamsManager";
            op.BGImager = global::WindowsFormsTest.Properties.Resources.sys_set;
            hashTable.Add(OperatorLabelEnum.SYSTEM_PARAM, op);
        }
        public static string GetOperatorLabelText(OperatorLabelEnum operatorLabel)
        {

            return hashTable[operatorLabel] == null ? "" : ((OperatorModel)hashTable[operatorLabel]).Label;
        }

        public static void Create_MainTabPage(OperatorLabelEnum operatorLabelEnum, MainTabUserContorl mainTabControl, WindowModel windowModel, MainForm mainForm)
        {
            mainTabControl.Dock = DockStyle.Fill;
            mainTabControl.SetModel(windowModel);
            TabPage tb = new TabPage();
            tb.Text = GetOperatorLabelText(operatorLabelEnum);
            tb.Controls.Add(mainTabControl);
            tb.TabIndex = mainForm.GetMainTabControl().Controls.Count;
            mainForm.GetMainTabControl().TabPages.Add(tb);
            mainForm.GetMainTabControl().SelectedTab = tb;

            mainTabControl.MainForm = mainForm;
            
        }

        public static void Create_MainTabPage(OperatorLabelEnum operatorLabelEnum, WindowModel windowModel, MainForm mainForm)
        {
            OperatorModel opModel = (OperatorModel)hashTable[operatorLabelEnum];
            object obj = Activator.CreateInstance(Type.GetType(opModel.MainTabClass));
            MainTabUserContorl mainTabControl = (MainTabUserContorl)obj;

            mainTabControl.Dock = DockStyle.Fill;
            mainTabControl.SetModel(windowModel);

            TabPage tb = new TabPage();
            tb.Text = opModel.Label;
            tb.Controls.Add(mainTabControl);
            tb.TabIndex = mainForm.GetMainTabControl().Controls.Count;
            mainForm.GetMainTabControl().TabPages.Add(tb);
            mainForm.GetMainTabControl().SelectedTab = tb;
            mainTabControl.MainForm = mainForm;
        }
      
       

    }
}
